<template>
    <rx-dialog @handOk="onOk" @cancel="onCancel">
        <rx-layout>
            <div slot="center" style>
                <rx-grid
                    :columns="columns"
                    :dataSource="dataSource"
                    ref="table"
                    :scroll = "{y:'calc( 100% - 51px )'}"
                    :allowRowSelect="true"
                    :multiSelect="false"
                    :showPage="false"
                >
                </rx-grid>
            </div>
        </rx-layout>
    </rx-dialog>
</template>

<script>

import {BaseList,Util, RxGrid,RxDialog,RxLayout} from "@lowcode/jpaas-common-lib";
import FormLiteFlowApi from '@/api/form/core/formLiteFlow'
export default {
    name: "LiteFlowBeanDialog",
    mixins: [BaseList],
    components: {
        RxDialog,
        RxLayout,
        RxGrid,
    },
    props:["type","layerid","destroy"],
    data() {
        return {
            dataSource:[],
            columns: [
                {
                    title: '序号',
                    type: 'indexColumn',
                    width: 100,
                    dataIndex: 'serial',
                    scopedSlots: {customRender: 'serial'}
                },
                {title: '处理器名称', dataIndex: 'label', width: 100},
                {title: '类名称', dataIndex: 'value', width: 100},
            ]
        }
    },
    created(){
        FormLiteFlowApi.getLiteFlowHandlers(this.type).then(res => {
            if (res) {
                this.dataSource = res;
            }
        });
    },
    methods:{
        onOk(){
            let row = this.$refs.table.getSelectedRow();
            if(!row || row.length==0){
                this.$message.warning("至少选择一条数据");
            }
            Util.closeWindow(this,'ok',row);
        },
        onCancel(){
            Util.closeWindow(this,'cancel');
        }
    }
}
</script>

<style scoped>

</style>